package com.dabai.dbatools;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

import com.dabai.dbutils.utils.DabaiUtils;
import com.dabai.qrtools.qrscanner.utils.ScannerUtils;


/**
 * @author BAI
 */
public class MainActivity extends AppCompatActivity {

    Context context;
    private Button mButton1;
    private Button mButton2;
    private Button mButton3;


    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initViews();

        context = this;


        mButton3.setOnClickListener(v -> {

            ScannerUtils.startQrCodeScanner(this,301);


        });


    }


    public boolean getTest() {
        Log.d("DBTAG", "getTest:123 ");
        return false;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (resultCode == Activity.RESULT_OK) {
            if (requestCode == 301) {
                if (data != null) {
                    String content = ScannerUtils.getQrCodeScannerResult(data);

                }
            }
        }

    }




    private void initViews() {
        mButton1 = findViewById(R.id.button1);
        mButton2 = findViewById(R.id.button2);
        mButton3 = findViewById(R.id.button3);
    }
}